package org.example.controller;
import org.example.domain.InsertUniqueUnloggedTable;
import org.example.service.IInsertUniqueUnloggedTableService;
import org.example.service.impl.InsertUniqueUnloggedTableServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.UUID;

/**
* unlogged插入幂等表(insert_unique_unlogged_table)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/insert_unique_unlogged")
public class InsertUniqueUnloggedTableController {
    private static final Logger log = LoggerFactory.getLogger(InsertUniqueUnloggedTableController.class);
    /**
* 服务对象
*/
    @Autowired
    private IInsertUniqueUnloggedTableService insertUniqueUnloggedTableService;


    @RequestMapping("/testInsertUnique")
    public int testInsertUnique() throws InterruptedException{
        UUID uuid = UUID.randomUUID();
        try {
            int i = insertUniqueUnloggedTableService.testInsertUnique(uuid.toString());
            if (i > 0) {
                log.info("插入成功");
            } else {
                log.info("插入失败");
            }
            return i;
        }catch (Exception e){
            log.error("插入异常", e);
        }
        return 0;
    }
}
